package cn.lay.controller;

import cn.lay.pojo.linkman;
import cn.lay.service.goodsService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private goodsService goodsService;

    /*查询所以*/
    @RequestMapping(value = "/findAll",method = RequestMethod.GET)
    public JSONObject findAll(Integer page, Integer limit){
       return goodsService.findAll(page,limit);
    }

    @RequestMapping(value = "/findTplPage",method = RequestMethod.GET)
    public JSONObject findTplPage(){
        return goodsService.findTplPage();
    }

    @RequestMapping(value = "/deleteById",method = RequestMethod.GET)
    public JSONObject deleteById(@RequestParam("id") int id){
        return goodsService.deleteById(id);
    }

   @RequestMapping(value = "/updateById",method = RequestMethod.POST)
   public JSONObject updateById(@RequestBody linkman linkman){
       return goodsService.updateById(linkman);
   }

   @RequestMapping(value = "/add",method = RequestMethod.POST)
   public JSONObject add(@RequestBody linkman linkman){
       return goodsService.add(linkman);
   }
}
